package com.wlyuan.index.domain.source.adapter;

import com.wlyuan.finance.dto.waybillfinance.WaybillFinanceEventDTO;
import com.wlyuan.index.api.dto.waybill.BalanceIndexDTO;
import lombok.EqualsAndHashCode;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

/**
 * @author yuanjie
 */
@EqualsAndHashCode(callSuper = true)
public class BalanceAdapter extends BalanceIndexDTO {
    @Mapper
    public interface Assembler {
        void assemble(@MappingTarget BalanceIndexDTO bill, BalanceIndexDTO source);

        BalanceIndexDTO translate(WaybillFinanceEventDTO source);
    }

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    public BalanceAdapter(BalanceIndexDTO source) {
        ASSEMBLER.assemble(this, source);
    }

    public static BalanceIndexDTO translate(WaybillFinanceEventDTO source) {
        return ASSEMBLER.translate(source);
    }
}
